package com.ruoyi.web.controller.tgis;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tgis.domain.AllServer;
import com.ruoyi.tgis.service.AllServerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 服务基础信息Controller
 * 
 * @author ljj
 * @date 2024-06-24
 */
@Api("tgis-服务管理")
@RestController
@RequestMapping("/tgis/allServer")
public class AllServerController extends BaseController {

    @Autowired
    private AllServerService allServerService;

    /**
     * 查询服务基础信息列表
     */
    @ApiOperation("查询服务基础信息列表")
    @PreAuthorize("@ss.hasPermi('tgis:allServer:list')")
    @GetMapping("/list")
    public TableDataInfo list(AllServer allServer){
        startPage();
        List<AllServer> list = allServerService.selectAllServerList(allServer);
        return getDataTable(list);
    }

    /**
     * 导出服务基础信息列表
     */
    @ApiOperation("导出服务基础信息列表")
    @PreAuthorize("@ss.hasPermi('tgis:allServer:export')")
    @Log(title = "服务基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AllServer allServer){
        List<AllServer> list = allServerService.selectAllServerList(allServer);
        ExcelUtil<AllServer> util = new ExcelUtil<AllServer>(AllServer.class);
        util.exportExcel(response, list, "服务基础信息数据");
    }

    /**
     * 获取服务基础信息详细信息
     */
    @ApiOperation("获取服务基础信息详细信息")
    @PreAuthorize("@ss.hasPermi('tgis:allServer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id){
        return success(allServerService.selectAllServerById(id));
    }

    /**
     * 新增服务基础信息
     */
    @ApiOperation("新增服务基础信息")
    @PreAuthorize("@ss.hasPermi('tgis:allServer:add')")
    @Log(title = "服务基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AllServer allServer){
        return toAjax(allServerService.insertAllServer(allServer));
    }

    /**
     * 修改服务基础信息
     */
    @ApiOperation("修改服务基础信息")
    @PreAuthorize("@ss.hasPermi('tgis:allServer:edit')")
    @Log(title = "服务基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AllServer allServer){
        return toAjax(allServerService.updateAllServer(allServer));
    }

    /**
     * 删除服务基础信息
     */
    @ApiOperation("删除服务基础信息")
    @PreAuthorize("@ss.hasPermi('tgis:allServer:remove')")
    @Log(title = "服务基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(allServerService.deleteAllServerByIds(ids));
    }
}
